package info.openlvb.openface.client.base.home;

import info.openlvb.openface.client.images.OpenFaceImages;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.gwtext.client.core.Function;
import com.gwtext.client.widgets.MessageBox;
import com.gwtext.client.widgets.Tool;
import com.gwtext.client.widgets.layout.ColumnLayoutData;
import com.gwtext.client.widgets.layout.FitLayout;
import com.gwtext.client.widgets.portal.Portal;
import com.gwtext.client.widgets.portal.PortalColumn;
import com.gwtext.client.widgets.portal.Portlet;

public class HomePanel extends VerticalPanel{

	OpenFaceImages images = GWT.create(OpenFaceImages.class);
	

	public HomePanel(){
		//super();
		/** Modification : Xavier
		 *  Modification de la largeur du HomePanel
		 */
		setWidth("99%");
		//setSize("80%", "80%");
		//create a portal  
		Portal portal = new Portal();
		/** Modification : Xavier
		 *  Modification de la largeur du portal et desactivation de
		 *  l'autoscroll
		 */
		portal.setWidth("98%");
		portal.setAutoScroll(false);

		//create some shared tools  
		Tool gear = new Tool(Tool.GEAR, new Function() {  
			public void execute() {  
				MessageBox.alert("Message", "The Settings Tool was clicked");  
			}  
		});  

		Tool close = new Tool(Tool.CLOSE, new Function() {  
			public void execute() {  
				MessageBox.alert("Message", "The Settings Tool was clicked");  
			}  
		});  

		Tool[] tools = new Tool[]{gear, close};
		

		//create portal columns  
		/** Modification : Xavier
		 *  Modification de la largeur des colonnes du portal
		 */
		PortalColumn firstCol = new PortalColumn();
		firstCol.setWidth("30%");
		firstCol.setPaddings(10, 10, 0, 10);
		PortalColumn secondCol = new PortalColumn();
		secondCol.setWidth("30%");
		secondCol.setPaddings(10, 10, 0, 10);
		PortalColumn thirdCol = new PortalColumn();
		thirdCol.setWidth("30%");
		thirdCol.setPaddings(10, 10, 0, 10);

		//add portlets to portal columns  
		final Portlet Host = new Portlet();  
		Host.setTitle("Host");  
		Host.setLayout(new FitLayout());  
		Host.setTools(tools);
		Host.add(new RRDService(Host).getVp());
		Portlet Vserver1 = new Portlet();  
		Vserver1.setTitle("Vserver1");  
		Vserver1.setLayout(new FitLayout());  
		Vserver1.setTools(tools);  
		Vserver1.add(new RRDService(Vserver1).getVp());
		Portlet Vserver2 = new Portlet();  
		Vserver2.setTitle("Vserver2");  
		Vserver2.setLayout(new FitLayout());  
		Vserver2.setTools(tools);  
		Vserver2.add(new RRDService(Vserver2).getVp());

		firstCol.add(Host);
		secondCol.add(Vserver1);
		thirdCol.add(Vserver2);
		//add portal column to portal
		/** Modification : Xavier
		 *  Modification de la largeur des colonnes du portal
		 */
		//portal.add(firstCol, new ColumnLayoutData(.30));
		//portal.add(secondCol, new ColumnLayoutData(.30));
		portal.add(firstCol, new ColumnLayoutData(.31));
		portal.add(secondCol, new ColumnLayoutData(.31));
		portal.add(thirdCol, new ColumnLayoutData(.31));
		add(portal);
		
	}
}


